<?php echo $this->doctype() ?>
<?php echo $this->headTitle('Панель управления') ?>
<?php echo $this->headMeta()->appendHttpEquiv('Content-Type', 'text/html; charset=UTF-8')->appendHttpEquiv('Content-Language', 'ru-RU') ?>
<?php echo $this->headLink()->appendStylesheet('/css/cp/main.css', 'screen')->appendStylesheet('/css/goog.css', 'screen') ?>
<!--[if IE]><link rel="stylesheet" href="/css/cp/ie6-main.css" type="text/css" /><![endif]-->
<style>
.logo:hover {
	cursor: pointer;
}
</style>
<script src="/js/closure/goog/base.js"></script>
<script src="/js/jquery/jquery.js"></script>
<script src="/js/jquery/jquery-ui.js"></script>
<script>
goog.require('goog.base');
goog.require('goog.array');
goog.require('goog.events');
goog.require('goog.events.EventType');
goog.require('goog.object');
goog.require('goog.ui.Css3MenuButtonRenderer');
goog.require('goog.ui.Menu');
goog.require('goog.ui.MenuButton');
goog.require('goog.ui.MenuItem');
goog.require('goog.ui.Separator');
goog.require('goog.ui.decorate');
goog.require('goog.ui.Dialog');
goog.require('goog.dom');
goog.require('goog.fx');
goog.require('goog.fx.dom');
goog.require('goog.net.XhrIo');
</script>
<div class="body-container">
  <div class="body-header">
    <div class="caption">
      <h1 onclick="window.location.pathname = '/cp';" class="logo">Панель управления</h1>
    </div>
    <div class="info-block">
      Здравствуй, <span id="user-menu"></span>
    </div>
    <div class="clear-fix"></div>
  </div>
  <div class="body-content-container">
    <div class="sidebar-left">
      <ul id="navigation">
        <li class="header">Навигация</li>
        <li><a href="/" target='_blank'>Перейти на сайт</a></li>
        <li class="separator"></li>
        <li><a href="/cp/settings/nav">Настройка навигации</a></li>
        <li class="separator"></li>
		<li><a href="/cp/news">Модуль - Новости</a></li>
        <li><a href="/cp/page">Модуль - Страницы</a></li>
		<li><a href="/cp/photo.albums">Модуль - Фотоальбом</a></li>
		<li class="separator"></li>
        <li><a href="/cp/group">Управление группами</a></li>
        <li><a href="/cp/user">Управление пользователями</a></li>
        <li><a href="/cp/resource">Управление ресурсами</a></li>
        <li class="separator"></li>
        <li><a href="/cp/files">Загруженные файлы</a></li>
      </ul>
    </div>
    <div class="body-content">
      <?php echo $this->layout()->content ?>
    </div>
    <div class="clear-fix"></div>
  </div>
</div>
<script>
var CP = {
	"EVENTS": goog.object.getValues(goog.ui.Component.EventType),
	"START": function() {
		var _self = this;
		// init user info block
		var userInfoMenu = new goog.ui.Menu();
		userInfoMenu.setId('menu-user-info');
		menuItems = [
			{
				"label": "Личные настройки",
				"id": "profile-settings",
				"url": "/cp/user/edit?id=<?php echo $this->client->user->id ?>"
			},
			{
				"label": "Выход",
				"id": "logout",
				"url": "/cp/auth/logout"
			}
		];
		goog.object.forEach(menuItems, function(i){
			var item = new goog.ui.MenuItem(i.label);
			item.setId(i.id);
			item.setDispatchTransitionEvents(goog.ui.Component.State.ALL, true);
			var a  = goog.dom.createDom('a', {"href": i.url}, i.label);
			item.addEventListener('action', function(e){
				window.location = i.url;
			});
			userInfoMenu.addItem(item);
		});
		var userInfoMenuButton = new goog.ui.MenuButton('<?php echo $this->client->user->name ?>', userInfoMenu, new goog.ui.Css3MenuButtonRenderer());
		userInfoMenuButton.setDispatchTransitionEvents(goog.ui.Component.State.ALL, true);
		userInfoMenuButton.render(goog.dom.getElement('user-menu'));
		$('#navigation a').each(function(){
			if ($(this).attr('href') == window.location.pathname) {
				var parent = $(this).parent();
				var text = $(this).text();
				parent.html('<div class="active">' + text + '</div>');
			}
		});
	}
};

CP.START();
</script>